/*
 * <one line to give the program's name and a brief idea of what it does.>
 * Copyright (C) 2019
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef TROPHY_H
#define TROPHY_H

#include "commondata.hpp"

class DataBase;

/**
 * \class Trophy
 * This class contain only static members.
 * All manipulations with trophy points must be done through this class
 */
class Trophy {
public:
	Trophy() = delete;
	Trophy(const Trophy & other) = delete;

	/**
	 * return how many trophy points player has on baseline
	 * \param[in] data pointer to PlayerData object
	 * \return amount of trophy points on baseline
	 */
	static uint32_t pointsBase(const PlayerData * data);

	/**
	 * return how many trophy points player has on test line
	 * this point NOT INCLUDE trophy points from ship's power by default!
	 * \param[in] data pointer to PlayerData object
	 * \param[in] power if true, ship power will be count
	 * \return amount of trophy points on test line
	 */
	static uint32_t pointsTest(const PlayerData * data, bool power = false);

	/**
	 * Convert amount of res to trophy levels
	 * \param[in] value amount of resource
	 * \return amount of trophy levels
	 * \todo TODO переписать, чтобы принимал сразу ресурс целиком
	 */
	static uint32_t levelFromResource(const uint32_t & value);

	/**
	 * Convert power to trophy levels
	 * \return trophy level
	 */
	static uint32_t levelFromPower(const uint32_t & power);

	/**
	 * Convert trophy level to trophy points
	 * \param[in] level trophy level
	 * \return how many total trophy points player get on this trophy level
	 */
	static uint32_t pointsFromLevelTotal(const uint32_t & level);

	/**
	 * Find how many times player can upgrade trophy dmg/hp with current trophy points
	 * \param[in] points trophy points
	 * \return amount of upgrades
	 */
	static uint32_t maxLevel(const uint32_t & points);

	/**
	 * Find all variants to spend trophy points
	 * \param[out] db where we put search results
	 * \param[in] data player data
	 */
	static void variants(DataBase * db, const PlayerData * data);

private:
	/**
	 * Common function for calculate trophy points
	 * \param[in] data player data
	 * \param[in] power if true, power will be included into trophy points, if false not include
	 * \param[in] base if true calculate points for baseline, if false for test line
	 * \return amount of available trophy points
	 */
	static uint32_t trophyPoints(const PlayerData * data, bool power, bool base);

	/**
	 * Calculate how many power points player have
	 * \param[in] data player data
	 * \param[in] base if true calculate points for baseline, if false for test line
	 * \return amount of power points
	 */
	static uint32_t powerPoints(const PlayerData * data, bool base);
};

#endif // TROPHY_H
